package com.behavioranalysis.flinkprogram.flink.ad;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple6;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <h3>flinkprogram</h3>
 * <p>${description}</p>
 * Created by yang on 20-2-14 下午9:14
 * updated by yang on 20-2-14 下午9:14
 */
public class Stream2TimeMinuteCountMapFunction implements
        MapFunction<
                Tuple6<Long, String, String, String, String, String>,
                Tuple2<String, Long>> {
    private static final long serialVersionUID = 1L;
    @Override
    public Tuple2<String, Long> map(
            Tuple6<Long, String, String, String, String, String> value) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
        String timeMinute = sdf.format(new Date(value.f0));
        long adid = Long.valueOf(value.f4);

        return new Tuple2<>(timeMinute + "_" + adid, 1L);
    }
}
